home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1050 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: sample auto_ptr template
  5. Date: 12 Apr 1996 14:57:27 GMT
  6. Organization: GABI Software, Sarl.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <KANZE.96Apr12130738@gabi.gabi-soft.fr>
  9. References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com>
  10.     <4kjcvb$ghf@ugress.uib.no>
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. X-Nntp-Posting-Host: gabi.gabi-soft.fr
  13. In-Reply-To: boukanov@sentef1.fi.uib.no's message of 11 Apr 1996 16:47:47 GMT
  14. Content-Length: 1430
  15. X-Lines: 30
  16. Originator: clamage@taumet
  17.  
  18. In article <4kjcvb$ghf@ugress.uib.no> boukanov@sentef1.fi.uib.no (Igor
  19. Boukanov) writes:
  20.  
  21. |> Greg Colvin (gregor@netcom.com) wrote:
  22. |> > This was a hard call, and I'm open to suggestions.  Adding a mutable
  23. |> > member to a class is never pretty, but making the member visible in any
  24. |> > way is ugly:  I don't like for a const argument to change its value,
  25. |> > and I think of the value of an object as being whatever its public
  26. |> > interface reveals. 
  27.  
  28. |> But why in this case instead of adding mutable member just change
  29. |> auto_ptr<T>(const auto_ptr<T>&) to auto_ptr<T>(auto_ptr<T>&)
  30. |> and 
  31. |> auto_ptr<T>& operator=(const auto_ptr<T>&) to
  32. |> auto_ptr<T>& operator=(auto_ptr<T>&)
  33.  
  34. |> This will explicitly reflect the semantic of auto_ptr and if somebody really 
  35. |> want to change the state of const object, they can explicitly wright
  36. |> about this:
  37. |> auto_ptr<someType> autoPtr(const_cast<auto_ptr<someType>&>(autoPtrConst)); 
  38.  
  39. We've been through all this before.  That was the original version.
  40. Regretfully, makes it impossible to return an auto_ptr from a function.
  41. And one of the more frequent uses of auto_ptr involves returning them
  42. from functions.
  43. -- 
  44. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  45. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  46. Conseils en informatique industrielle --
  47.                             -- Beratung in industrieller Datenverarbeitung
  48.  
  49.  
  50. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  51. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  52. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  53. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  54. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  55.